home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 220 / 220.xpi / chrome / flashgot.jar / content / flashgot / flashgotCommon.js < prev    next >
Encoding:
JavaScript  |  2010-01-24  |  1.7 KB  |  49 lines

  1. /***** BEGIN LICENSE BLOCK *****
  2.  
  3.     FlashGot - a Firefox extension for external download managers integration
  4.     Copyright (C) 2004-2009 Giorgio Maone - g.maone@informaction.com
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.                              
  20. ***** END LICENSE BLOCK *****/
  21.  
  22. var gFlashGotService = (function() {
  23.   var fg = null;
  24.   for(var attempt = 1; attempt <= 2; attempt++) {
  25.     try {
  26.      fg = Components.classes["@maone.net/flashgot-service;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
  27.      if(attempt == 2 && fg.dirtyJobs) fg.dirtyJobs();
  28.      break;
  29.     } catch(ex) {
  30.       dump(ex.message);
  31.       window.navigator.plugins.refresh();
  32.     }
  33.   }
  34.   fg.init();
  35.   return fg;
  36. })();
  37.  
  38. var flashgotUtil = {
  39.   browse: function(url, feature) {
  40.     var w = gFlashGotService.dom.mostRecentBrowserWindow;
  41.     if(w && !w.closed) {
  42.       var browser = w.getBrowser();
  43.       browser.selectedTab = browser.addTab(url);
  44.     } else {
  45.       window.open(url, "_blank", features || null)
  46.     }
  47.   }
  48. };
  49.